// 新增计划
const { ObjectId } = require('mongodb');
const {
    DayPlan
} = require('../../../model/plan/dayPlan');


module.exports = async (req, res) => {
    let plan = req.fields;
    Object.keys(plan).forEach(key => {
        if (key === 'startTime' || key === 'endTime') {
            plan[key] = new Date(plan[key]).getTime();
        }
    });

    await DayPlan.updateOne({ _id: ObjectId(req.fields.id) }, plan)
    res.send({ 'code': 0 });
}